<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
    <h:head>
        <title>Owner</title>
        <link href="css/global.css" rel="stylesheet" type="text/css" />
        <script src="http://code.jquery.com/jquery-latest.js"></script>
        <script src="js/global.js"></script>
        <link href="resources/DataTables-1.9.4/media/css/jquery.dataTables.css" rel="stylesheet" type="text/css"/>
        <script src="resources/DataTables-1.9.4/media/js/jquery.dataTables.js"/>
        <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" type="text/css" />
        <script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>

        <script language="javascript">
            $(document).ready(function(){
                $("[id$='owner']").dataTable();
                $("div.navy").load("navy.xhtml");
                
                var resultList = document.getElementById("resultList").value; 
               
                var array = resultList.split(',');
                
                $("[id$=_autocomplete]").autocomplete({
                    source: array
                });
                
            });
        </script>

    </h:head>
    <h:body>

        <h:inputHidden id="resultList" value="#{findFantasyUserBean.emailList}" /> 
        <h:inputHidden id="leagueId" value="1" /> 
        <h:inputHidden id="maxNumberOfMember" value="4" /> 
        <div id="background">
            <div class="navy">

            </div>
            <div id="content">
                <div id="ownerDiv">
                    <span class="whiteHeader">Owner</span><br/><br/>
                    <table id="owner">
                        <thead>
                            <tr>
                                <th scope="col">Team</th>
                                <th scope="col">Owner</th>
                                <th scope="col">Add/Ban</th>
                                <th scope="col">Last Activity</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <h:form>
                                    <td>
                                        <c:choose>
                                            <c:when test="#{!empty accountBean.team1}">
                                                <h:outputLabel id="team1" value="#{accountBean.team1.name}" />
                                                <h:inputHidden id="ban1" value="#{accountBean.team1.id}" />
                                            </c:when>
                                            <c:otherwise>
                                                <h:inputText id="team1_autocomplete" value="#{ownerBean.id1}"  />  
                                            </c:otherwise>
                                        </c:choose>
                                    </td>

                                    <td><h:outputLabel id="owner1" value="#{accountBean.team1.userId.loginName}" /></td>
                                    <td>
                                        <c:choose>
                                            <c:when test="#{accountBean.account == accountBean.currentLeagueOwner}">
                                                <c:choose>
                                                    <c:when test="#{!empty accountBean.team1}">
                                                        <h:commandButton id="banTeam1" action="#{ownerBean.banTeam(1)}" value="Ban"  >
                                                            <f:param name="action" value="#{accountBean.team1.id}" /> 
                                                        </h:commandButton>
                                                    </c:when>
                                                    <c:otherwise>
                                                        <h:commandButton id="inviteTeam1" action="#{ownerBean.inviteTeam(1)}" value="Invite" />  
                                                    </c:otherwise>
                                                </c:choose>
                                            </c:when>
                                            <c:otherwise>
                                            </c:otherwise>
                                        </c:choose>
                                    </td>
                                    <td></td>
                                </h:form>
                            </tr>
                            <tr>
                                <h:form>
                                    <td>
                                        <c:choose>
                                            <c:when test="#{!empty accountBean.team2}">
                                                <h:outputLabel id="team2" value="#{accountBean.team2.name}" />
                                                <h:inputHidden id="ban2" value="#{accountBean.team2.id}" />
                                            </c:when>
                                            <c:otherwise>
                                                <h:inputText id="team2_autocomplete" value="#{ownerBean.id2}"  />  
                                            </c:otherwise>
                                        </c:choose>
                                    </td>
                                    <td><h:outputLabel id="owner2" value="#{accountBean.team2.userId.loginName}" /></td>
                                    <td>
                                        <c:choose>
                                            <c:when test="#{accountBean.account == accountBean.currentLeagueOwner}">
                                                <c:choose>
                                                    <c:when test="#{!empty accountBean.team2}">
                                                        <h:commandButton id="banTeam2" action="#{ownerBean.banTeam(2)}" value="Ban"  >
                                                            <f:param name="action" value="#{accountBean.team2.id}" />
                                                        </h:commandButton>
                                                    </c:when>
                                                    <c:otherwise>
                                                        <h:commandButton id="inviteTeam2" action="#{ownerBean.inviteTeam(2)}" value="Invite" />  
                                                    </c:otherwise>
                                                </c:choose>
                                            </c:when>
                                            <c:otherwise>
                                            </c:otherwise>
                                        </c:choose>
                                    </td>
                                    <td></td>
                                </h:form>
                            </tr>
                            <tr>
                                <h:form>
                                    <td>
                                        <c:choose>
                                            <c:when test="#{!empty accountBean.team3}">
                                                <h:outputLabel id="team3" value="#{accountBean.team3.name}" />
                                                <h:inputHidden id="ban3" value="#{accountBean.team3.id}" />
                                            </c:when>
                                            <c:otherwise>
                                                <h:inputText id="team3_autocomplete" value="#{ownerBean.id3}"  />  
                                            </c:otherwise>
                                        </c:choose>
                                    </td>
                                    <td><h:outputLabel id="owner3" value="#{accountBean.team3.userId.loginName}" /></td>
                                    <td>
                                        <c:choose>
                                            <c:when test="#{accountBean.account == accountBean.currentLeagueOwner}">
                                                <c:choose>
                                                    <c:when test="#{!empty accountBean.team3}">
                                                        <h:commandButton id="banTeam3" action="#{ownerBean.banTeam(3)}" value="Ban"  >
                                                            <f:param name="action" value="#{accountBean.team3.id}" />
                                                        </h:commandButton>
                                                    </c:when>
                                                    <c:otherwise>
                                                        <h:commandButton id="inviteTeam3" action="#{ownerBean.inviteTeam(3)}" value="Invite" />  
                                                    </c:otherwise>
                                                </c:choose>
                                            </c:when>
                                            <c:otherwise>
                                            </c:otherwise>
                                        </c:choose>
                                    </td>
                                    <td></td>
                                </h:form>
                            </tr>
                            <tr>
                                <h:form>
                                    <td>
                                        <c:choose>
                                            <c:when test="#{!empty accountBean.team4}">
                                                <h:outputLabel id="team4" value="#{accountBean.team4.name}" />
                                                <h:inputHidden id="ban4" value="#{accountBean.team4.id}" />
                                            </c:when>
                                            <c:otherwise>
                                                <h:inputText id="team4_autocomplete" value="#{ownerBean.id4}"  />  
                                            </c:otherwise>
                                        </c:choose>
                                    </td>
                                    <td><h:outputLabel id="owner4" value="#{accountBean.team4.userId.loginName}" /></td>
                                    <td>
                                        <c:choose>
                                            <c:when test="#{accountBean.account == accountBean.currentLeagueOwner}">
                                                <c:choose>
                                                    <c:when test="#{!empty accountBean.team4}">
                                                        <h:commandButton id="banTeam4" action="#{ownerBean.banTeam(4)}" value="Ban"  >
                                                            <f:param name="action" value="#{accountBean.team4.id}" />
                                                        </h:commandButton>
                                                    </c:when>
                                                    <c:otherwise>
                                                        <h:commandButton id="inviteTeam4" action="#{ownerBean.inviteTeam(4)}" value="Invite" />  
                                                    </c:otherwise>
                                                </c:choose>
                                            </c:when>
                                            <c:otherwise>
                                            </c:otherwise>
                                        </c:choose>
                                    </td>
                                    <td></td>
                                </h:form>
                            </tr>
                            <tr>
                                <h:form>
                                    <td>
                                        <c:choose>
                                            <c:when test="#{!empty accountBean.team5}">
                                                <h:outputLabel id="team5" value="#{accountBean.team5.name}" />
                                                <h:inputHidden id="ban5" value="#{accountBean.team5.id}" />
                                            </c:when>
                                            <c:otherwise>
                                                <h:inputText id="team5_autocomplete" value="#{ownerBean.id5}"  />  
                                            </c:otherwise>
                                        </c:choose>
                                    </td>
                                    <td><h:outputLabel id="owner5" value="#{accountBean.team5.userId.loginName}" /></td>
                                    <td>
                                        <c:choose>
                                            <c:when test="#{accountBean.account == accountBean.currentLeagueOwner}">
                                                <c:choose>
                                                    <c:when test="#{!empty accountBean.team5}">
                                                        <h:commandButton id="banTeam5" action="#{ownerBean.banTeam(5)}" value="Ban"  >
                                                            <f:param name="action" value="#{accountBean.team5.id}" />
                                                        </h:commandButton>
                                                    </c:when>
                                                    <c:otherwise>
                                                        <h:commandButton id="inviteTeam5" action="#{ownerBean.inviteTeam(5)}" value="Invite" />  
                                                    </c:otherwise>
                                                </c:choose>
                                            </c:when>
                                            <c:otherwise>
                                            </c:otherwise>
                                        </c:choose>
                                    </td>
                                    <td></td>
                                </h:form>
                            </tr>
                            <tr>
                                <h:form>
                                    <td>
                                        <c:choose>
                                            <c:when test="#{!empty accountBean.team6}">
                                                <h:outputLabel id="team6" value="#{accountBean.team6.name}" />
                                                <h:inputHidden id="ban6" value="#{accountBean.team6.id}" />
                                            </c:when>
                                            <c:otherwise>
                                                <h:inputText id="team6_autocomplete" value="#{ownerBean.id6}"  />  
                                            </c:otherwise>
                                        </c:choose>
                                    </td>
                                    <td><h:outputLabel id="owner6" value="#{accountBean.team6.userId.loginName}" /></td>
                                    <td>
                                        <c:choose>
                                            <c:when test="#{accountBean.account == accountBean.currentLeagueOwner}">
                                                <c:choose>
                                                    <c:when test="#{!empty accountBean.team6}">
                                                        <h:commandButton id="banTeam6" action="#{ownerBean.banTeam(6)}" value="Ban"  >
                                                            <f:param name="action" value="#{accountBean.team6.id}" />
                                                        </h:commandButton>
                                                    </c:when>
                                                    <c:otherwise>
                                                        <h:commandButton id="inviteTeam6" action="#{ownerBean.inviteTeam(6)}" value="Invite" />  
                                                    </c:otherwise>
                                                </c:choose>
                                            </c:when>
                                            <c:otherwise>
                                            </c:otherwise>
                                        </c:choose>
                                    </td>
                                    <td></td>
                                </h:form>
                            </tr>
                            <tr>
                                <h:form>
                                    <td>
                                        <c:choose>
                                            <c:when test="#{!empty accountBean.team7}">
                                                <h:outputLabel id="team7" value="#{accountBean.team7.name}" />
                                                <h:inputHidden id="ban7" value="#{accountBean.team7.id}" />
                                            </c:when>
                                            <c:otherwise>
                                                <h:inputText id="team7_autocomplete" value="#{ownerBean.id7}"  />  
                                            </c:otherwise>
                                        </c:choose>
                                    </td>
                                    <td><h:outputLabel id="owner7" value="#{accountBean.team7.userId.loginName}" /></td>
                                    <td>
                                        <c:choose>
                                            <c:when test="#{accountBean.account == accountBean.currentLeagueOwner}">
                                                <c:choose>
                                                    <c:when test="#{!empty accountBean.team7}">
                                                        <h:commandButton id="banTeam7" action="#{ownerBean.banTeam(7)}" value="Ban"  >
                                                            <f:param name="action" value="#{accountBean.team7.id}" />
                                                        </h:commandButton>
                                                    </c:when>
                                                    <c:otherwise>
                                                        <h:commandButton id="inviteTeam7" action="#{ownerBean.inviteTeam(7)}" value="Invite" />  
                                                    </c:otherwise>
                                                </c:choose>
                                            </c:when>
                                            <c:otherwise>
                                            </c:otherwise>
                                        </c:choose>
                                    </td>
                                    <td></td>
                                </h:form>
                            </tr>
                            <tr>
                                <h:form>
                                    <td>
                                        <c:choose>
                                            <c:when test="#{!empty accountBean.team8}">
                                                <h:outputLabel id="team8" value="#{accountBean.team8.name}" />
                                                <h:inputHidden id="ban8" value="#{accountBean.team8.id}" />
                                            </c:when>
                                            <c:otherwise>
                                                <h:inputText id="team8_autocomplete" value="#{ownerBean.id8}"  />  
                                            </c:otherwise>
                                        </c:choose>
                                    </td>
                                    <td><h:outputLabel id="owner8" value="#{accountBean.team8.userId.loginName}" /></td>
                                    <td>
                                        <c:choose>
                                            <c:when test="#{accountBean.account == accountBean.currentLeagueOwner}">
                                                <c:choose>
                                                    <c:when test="#{!empty accountBean.team8}">
                                                        <h:commandButton id="banTeam8" action="#{ownerBean.banTeam(8)}" value="Ban" actionListener="#{ownerBean.attrListener}" >
                                                            <f:param name="action" value="#{accountBean.team8.id}" />
                                                        </h:commandButton>

                                                    </c:when>
                                                    <c:otherwise>
                                                        <h:commandButton id="inviteTeam8" action="#{ownerBean.inviteTeam(8)}" value="Invite" />  
                                                    </c:otherwise>
                                                </c:choose>
                                            </c:when>
                                            <c:otherwise>
                                            </c:otherwise>
                                        </c:choose>

                                    </td>
                                    <td></td>
                                </h:form>
                            </tr>
                        </tbody>
                    </table>  
                </div>
            </div>
        </div>
    </h:body>
</html>
